/*
 * @Author: adolphus adolphus520@163.com
 * @Date: 2022-12-05 17:54:25
 * @LastEditors: 姚杰鸿
 * @LastEditTime: 2024-11-11 18:20:36
 * @Description: file content
 */
import { createApp, h } from "vue";

import "@/styles/index.scss";
import "./style.css";

import App from "./App.vue";
import router from "./router";
import { store, key, localStore } from "@/store";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import { getElementLabelLine } from "element-tree-line";
import { install } from "@icon-park/vue-next/es/all";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import "@imengyu/vue3-context-menu/lib/vue3-context-menu.css";
import ContextMenu from "@imengyu/vue3-context-menu";

// css
import "element-tree-line/dist/style.css";

/* import the fontawesome */
import { library } from "@fortawesome/fontawesome-svg-core";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { fas } from "@fortawesome/free-solid-svg-icons";
import { far } from "@fortawesome/free-regular-svg-icons";
import { fab } from "@fortawesome/free-brands-svg-icons";
import { IconDefinition } from "@fortawesome/fontawesome-common-types";

/* add icons to the library */
const fortawesomeLibraryAdd = (icons: any) => {
  const keys = Object.keys(icons);
  for (const key of keys) {
    const icon = icons[key];
    if ((icon as IconDefinition).prefix !== undefined) {
      library.add(icon);
    }
  }
};
library.add(fas, far, fab);

const app = createApp(App);
install(app);
app.config.globalProperties.$icons = [];
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.config.globalProperties.$icons.push(key);
  app.component(key, component);
}
const ElementLabelLine = getElementLabelLine(h);
app.component(ElementLabelLine.name, ElementLabelLine);
app.component("FontAwesomeIcon", FontAwesomeIcon);

app.use(store, key);
store.commit(localStore);
app.use(router).use(ContextMenu).mount("#app");
app.use(ElementPlus, {
  locale: zhCn,
});
